package com.zds.zds_picture_backend.exception;/*
 *@auther 郑笃实
 *@version 1.0
 *
 */

public class ThrowUtils {
    /**
     * @param condition        判断条件
     * @param runtimeException 异常
     */
    public static void throwIf(boolean condition, RuntimeException runtimeException) {
        if (condition) {
            throw runtimeException;
        }
    }

    /**
     * @param condition 判断条件
     * @param errorCode 错误码
     */
    public static void throwIf(boolean condition, ErrorCode errorCode) {
        throwIf(condition, new BusinessException(errorCode));
    }

    /**
     * @param condition 判断条件
     * @param errorCode
     * @param message
     * @Description: 抛出异常
     */

    public static void throwIf(boolean condition, ErrorCode errorCode, String message) {
        throwIf(condition, new BusinessException(errorCode, message));
    }

}

